﻿// Decompiled with JetBrains decompiler
// Type: NetworkMessages.FromServer.MultiplayerIntermissionUpdate
// Assembly: TaleWorlds.MountAndBlade, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: D5209D1B-76B5-47CA-B957-255CD4B2CE6B
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.dll

using TaleWorlds.MountAndBlade;
using TaleWorlds.MountAndBlade.Network.Messages;

#nullable disable
namespace NetworkMessages.FromServer
{
  [DefineGameNetworkMessageType(GameNetworkMessageSendType.FromServer)]
  public sealed class MultiplayerIntermissionUpdate : GameNetworkMessage
  {
    public MultiplayerIntermissionState IntermissionState { get; private set; }

    public float IntermissionTimer { get; private set; }

    public MultiplayerIntermissionUpdate()
    {
    }

    public MultiplayerIntermissionUpdate(
      MultiplayerIntermissionState intermissionState,
      float intermissionTimer)
    {
      this.IntermissionState = intermissionState;
      this.IntermissionTimer = intermissionTimer;
    }

    protected override bool OnRead()
    {
      bool bufferReadValid = true;
      this.IntermissionState = (MultiplayerIntermissionState) GameNetworkMessage.ReadIntFromPacket(CompressionBasic.IntermissionStateCompressionInfo, ref bufferReadValid);
      this.IntermissionTimer = GameNetworkMessage.ReadFloatFromPacket(CompressionBasic.IntermissionTimerCompressionInfo, ref bufferReadValid);
      return bufferReadValid;
    }

    protected override void OnWrite()
    {
      GameNetworkMessage.WriteIntToPacket((int) this.IntermissionState, CompressionBasic.IntermissionStateCompressionInfo);
      GameNetworkMessage.WriteFloatToPacket(this.IntermissionTimer, CompressionBasic.IntermissionTimerCompressionInfo);
    }

    protected override MultiplayerMessageFilter OnGetLogFilter()
    {
      return MultiplayerMessageFilter.Administration;
    }

    protected override string OnGetLogFormat() => "Receiving runtime intermission state.";
  }
}
